package org.aurora.remote.protocol;

import java.util.HashMap;
import java.util.Map;

public class RemoteHeader {
    private volatile Map<String, Object> dataMap = new HashMap<>();

    public void putHeader(String key, Object val) {
        getDataMap().put(key, val);
    }

    public <T> T getHeader(String key) {
        return (T) getDataMap().get(key);
    }

    private Map<String, Object> getDataMap() {
        if (dataMap == null) {
            synchronized (this) {
                if (dataMap == null) {
                    dataMap = new HashMap<>();
                }
            }
        }
        return dataMap;
    }
}
